/*
 * Copyright (c) 2014 laidian. All Rights Reserved.
 *
 * @author yaoyuming
 *
 * @date 2019-11-29 15:51
 */
package com.yao;

import cn.hutool.core.date.DateUtil;
import cn.hutool.core.date.TimeInterval;
import cn.hutool.core.lang.Console;
import com.yao.util.CustMapUtil;
import com.yao.util.GeneratorUtil;
import org.apache.maven.plugin.AbstractMojo;
import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.plugin.MojoFailureException;

/**
 * 启动类
 *
 * @author yaoyuming
 * @goal generate-with-word
 * @phase process-sources
 * @date 2019/11/29 15:51
 */
public class CoreMain extends AbstractMojo {

    /**
     * @parameter
     */
    private String file;

    /**
     * @parameter
     */
    private String basepackage;


    /**
     * @parameter
     */
    private String destPath = "d:/te";

    @Override
    public void execute() throws MojoExecutionException, MojoFailureException {
        TimeInterval timer = DateUtil.timer();
        Console.log("destPath = "+ destPath);
        initMap();
        GeneratorUtil.gen(file);
        Console.log("生成代码执行完成，耗时: {} ms", timer.interval());
    }

    public void initMap() {
        CustMapUtil.setPackage(basepackage, destPath);
    }

    public static void main(String[] args) throws MojoFailureException, MojoExecutionException {

        new CoreMain().
                initMap();
        GeneratorUtil.gen(null);
    }
}